package com.atchangsha.system.controller;

import com.atchangsha.system.common.utils.Result;
import com.atchangsha.system.dto.PayDTO;
import com.atchangsha.system.service.PayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 支付
 */
@RestController
@RequestMapping("/system")
@Slf4j
public class PayController {
    @Resource
    private PayService payService;

    /**
     * 调用支付宝API
     * @param payDTO
     * @return
     */
    @PostMapping("/pay")
    public String pay(@RequestBody PayDTO payDTO){
        return payService.pay(payDTO);
    }

    /**
     * 消费订单
     * @param map
     * @param httpServletResponse
     */
    @GetMapping("/consumer")
    public void consumer(@RequestParam Map<String,String> map, HttpServletResponse httpServletResponse){
        payService.consumer(map,httpServletResponse);
    }

    /**
     * 现金支付
     * @param payDTO
     * @return
     */
    @PostMapping("/payCash")
    public Result payCash(@RequestBody PayDTO payDTO){
        return payService.payCash(payDTO);
    }
}
